package com.njts.other;
// 如果需要使用其他package的类,首先在类的外部(上方)用import 进行导入,(java.lang包除外) 只有public class才能import
import com.njts.extend.User;

/**
 * @author David GE
 * Date  2025/11/19
 */
public class ProtectedTest {
    public static void main(String[] args) {
        //User user = new User();
        //user.role = "管理员";//报错 因为变量是被protected修饰
        Nurse nurse = new Nurse();
        nurse.setRole("护士");
        System.out.println(nurse.getRole());
    }
}
class Nurse extends User{
    public void setRole(String role){
        this.role=role;
    }
    public String getRole(){
        return this.role;
    }
}
